package com.ruoyi.service.jpjs.municipal.impl;

import com.ruoyi.common.constant.MsgConstants;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.domain.jpjs.common.municipal.AnnualTarget;
import com.ruoyi.mapper.jpjs.income.TargetMapper;
import com.ruoyi.service.jpjs.municipal.TargetService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @explain 市政收入 业务层处理
 */
@Service
public class TargetServiceImpl implements TargetService {

    @Resource
    private TargetMapper targetMapper;

    @Override
    public List<AnnualTarget> queryTargetList(AnnualTarget annualTarget) {
        return targetMapper.queryTargetList(annualTarget);
    }

    @Override
    public int addTarget(AnnualTarget annualTarget) {
        return targetMapper.addTarget(annualTarget);
    }

    @Override
    public int updateTarget(AnnualTarget annualTarget) {
        return targetMapper.updateTarget(annualTarget);
    }

    @Override
    public String checkActualYearUnique(AnnualTarget annualTarget) {
        int actualCount = targetMapper.checkActualYearUnique(annualTarget);
        if (actualCount > 0) {
            return MsgConstants.MONTH_NOT_UNIQUE;
        }
        return MsgConstants.MONTH_UNIQUE;
    }

    @Override
    public String checkActualYearUniqueEdit(AnnualTarget annualTarget) {
        int actualCount = targetMapper.checkActualYearUniqueEdit(annualTarget);
        if (actualCount > 0) {
            return MsgConstants.MONTH_NOT_UNIQUE;
        }
        return MsgConstants.MONTH_UNIQUE;
    }

    @Override
    public int deleteTargetById(String target) {
        String[] targetId = Convert.toStrArray(target);
        return targetMapper.deleteTargetById(targetId);
    }


}
